package com.mm;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

@EnableCircuitBreaker   //开启断路器功能
@SpringBootApplication(
        //SpringBoot启动会自动注入数据源和配置jpa,这里排除掉
        exclude={DataSourceAutoConfiguration.class,HibernateJpaAutoConfiguration.class}
)
//将服务注册到注册管理中心
@EnableDiscoveryClient
public class HystrixApplication {
    @Bean
    @LoadBalanced
        //开启客户端负载均衡
    RestTemplate restTemplate(){
        return new RestTemplate();
    }
    public static void main(String[] args) {
        SpringApplication.run(HystrixApplication.class, args);
    }
}
